package no.ntnu.fp.gui;

import java.util.logging.Logger;

import javax.swing.JFrame;

public class ClientProgramStart implements Runnable{
	/**
	 * Run client from here
	 * @param args
	 */
	static ClientProgramStart cps = new ClientProgramStart();
	private Thread hostThread;
	private static GUITest GT = null;
	boolean loggedIn = false;
	String currentUser;	
	
	public static void main(String[] args){
		
		
		LoginWindow mw = new LoginWindow();
		
		mw.start();
		
		//GUITest g = new GUITest();
		
		
	}
	
	
	
	/**
	 * Login successfull.
	 * @param username 
	 */
	public void loginOk(String username){
		loggedIn = true;
		currentUser = username;
		hostThread = new Thread(this);
		hostThread.start();
	}



	@Override
	public void run() {
		if(ClientProgramStart.GT==null){
			ClientProgramStart.GT = new GUITest(currentUser);
			ClientProgramStart.GT.start();
		}
		else if(!loggedIn){
			GT.close();		}
	}
	
	
}
